from django.db import models
from common.db import BaseModel
# Create your models here.
#djago自带的用户认证模型
from django.contrib.auth.models import AbstractUser
class User(AbstractUser,BaseModel):
    """用户模型"""
    mobile=models.CharField(default='',max_length=11)
    avatar=models.ImageField(blank=True,null=True)


    class Meta:
        db_table='user' #表名
        verbose_name='用户表' #后台显示名称
        verbose_name_plural=verbose_name#去掉s

class Addr(models.Model):
    """收货地址"""
    user=models.ForeignKey('User',on_delete=models.CASCADE)#级联删除
    phone=models.CharField(max_length=11,default='')
    name=models.CharField(max_length=22)
    province=models.CharField(max_length=20)
    city=models.CharField(max_length=20)
    country=models.CharField(max_length=20)
    address=models.CharField(max_length=100)
    is_default=models.BooleanField(default=False)

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'Addr'  # 表名
        verbose_name = '地址表'  # 后台显示名称
        verbose_name_plural = verbose_name

class Area(models.Model):
    """省市区"""
    pid=models.IntegerField()
    name=models.CharField(max_length=20)
    level=models.CharField(max_length=20)

    def __str__(self):
        return self.name
    class Meta:
        db_table = 'Area'  # 表名
        verbose_name = '地区表'  # 后台显示名称
        verbose_name_plural = verbose_name
class VerCode(models.Model):
    """验证码模型"""
    mobile=models.CharField(max_length=11)
    code=models.CharField(max_length=6)
    create_time=models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table = 'VerCode'  # 表名
        verbose_name = '验证码表'  # 后台显示名称
        verbose_name_plural = verbose_name

















